#ifndef SIP_DIALOGSET_HPP__
#define SIP_DIALOGSET_HPP__

#include "SipResipConfigure.hpp"
//#include "SipUserAgent.hpp"
//#include "SipDialog.hpp"

#include "rutil/Data.hxx"
#include "resip/stack/SipMessage.hxx"

#include <deque>
#include <map>

using namespace resip;

namespace wtsip{

class CSipUserAgent;
class CSipInviteDialog;
class CSipRegistration;
class CSipSubscription;
class CSipDialogBase;
class CSipDlgTimeOut;
class CSipDlgAction;

//class RESIP_PUBLIC CSipDlgSetHandle{
//public:
//    virtual bool onInviteComing(CSipInviteDialog& dlg) = 0;
//
//    virtual bool onRegisterComing(CSipDialogBase& dlg) = 0;
//};


class RESIP_PUBLIC CSipDialogSet{
public:

    CSipDialogSet(CSipUserAgent& ua);

    virtual ~CSipDialogSet();    

    //bool setDlgSetHandle(CSipDlgSetHandle* handle);

    CSipInviteDialog* createInviteDlg(SipMessage& msg);

    CSipInviteDialog* createInviteDlg(const resip::Uri& remote, const resip::Uri& local);

    CSipRegistration* createRegistration(SipMessage& msg);

    CSipRegistration* createRegistration(const resip::Uri& remote, const resip::Uri& local);

    CSipSubscription* createSubscription(SipMessage& msg);

    CSipSubscription* createSubscription(const resip::Uri& remote, const resip::Uri& local);

    CSipDialogBase* createDialog(SipMessage& msg);
    
    CSipDialogBase* matchDialog(const resip::Data& id);

    CSipDialogBase* matchDialog(SipMessage& msg);

    bool destroyDialog(const resip::Data& id);

    bool isDialogRequest(SipMessage& msg);

    //bool postTimeOut(CSipDlgTimeOut& tOut, int seconds);

    //static bool toNameAddr(const Data& target, const Data& tUri, const int port, NameAddr& nAddr);

    CSipUserAgent& getUserAgent(){ return m_ua; }

private:

    std::map<resip::Data, CSipDialogBase*> m_DialogsMap;

    //std::deque<const resip::Data*> m_shutdownFifo;

    //std::deque<CSipDlgAction*> m_DlgActions;

    //CSipDlgSetHandle* m_dlgSetHandle;

    CSipUserAgent& m_ua;
};

}

#endif
